package com.ali.framework.utils;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by Unborn on 11/18/20.
 */
public class MyUtils {
    public static String getNowWeek() {
        return getWeek(0);
    }

    public static String getWeek(int index) {
        Date dNow = new Date();
        int dAfterIndex;
        String week = "";
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dNow);
        calendar.add(Calendar.DAY_OF_MONTH, index);
        dAfterIndex = calendar.get(Calendar.DAY_OF_WEEK);
        switch (dAfterIndex) {
            case 1:
                week = "星期天";
                break;
            case 2:
                week = "星期一";
                break;
            case 3:
                week = "星期二";
                break;
            case 4:
                week = "星期三";
                break;
            case 5:
                week = "星期四";
                break;
            case 6:
                week = "星期五";
                break;
            case 7:
                week = "星期六";
                break;
        }
        return week;
    }
}
